#include <bits/stdc++.h>
#define int long long
using namespace std;

int n, b[100010], a[100010], m[100010], ans;

signed main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    m[i] = a[i] + b[i];
    ans += max(a[i], b[i]);
  }
  sort(m + 1, m + 1 + n);
  for (int i = 1; i <= n / 2; ++i)
    ans -= m[i];
  cout << ans << endl;
}
